//package controller1;
//
//import com.wuchao.entity.User;
//import com.wuchao.service.serviceImpl.ServiceImpl;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.io.PrintWriter;
//import java.util.List;
//
///**
// * @Author wuchao66
// * @Date 2022/7/5 14:19
// * @Version 1.0
// */
//@WebServlet(name = "ServletAjax151",urlPatterns = "/ServletAjax151")
////注解 标注解释说明
//public class ServletAjax151 extends HttpServlet {//中转页的协议
//    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        request.setCharacterEncoding("utf-8");
//        response.setContentType("text/html;charset=utf-8");
//        PrintWriter out = response.getWriter();//文件流
//
//        out.flush();
//        out.close();
//    }
////默认get
//    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        response.setCharacterEncoding("utf-8");
//        response.setContentType("text/html;charset=utf-8");
//       // HttpSession session = (HttpSession)request.getSession();
//        PrintWriter out = response.getWriter();//文件流
//        ServiceImpl service = new ServiceImpl();
//        String name=request.getParameter("name");
//        System.out.println(name);
//        List<User> list = service.findPoJo("select * from user where name like ?", "%" + name + "%");
//        StringBuffer sb=new StringBuffer("[");
//        for(int i=0;i<list.size();i++){
//            String s="{\"name\":\""+list.get(i).getName()+"\",\"sex\":\""+list.get(i).getSex()+"\"}";
//            sb.append(s);
//            if(i<list.size()-1){
//                sb.append(",");
//            }
//        }
//        sb.append("]");
//        System.out.println(sb);
//        out.print(sb);
//
//
//       /* int loading = service.isLoading("select  count(1) from user where name =?", name);
//        System.out.println(loading);
//        if(loading>0){
//            out.println("y");
//        }else{
//            out.println("n");
//        }*/
//
//
//
//
//       /* String op = request.getParameter("op");
//        if(op!=null){
//            ServiceImpl service = new ServiceImpl();
//            if(op.equals("delete")){//判断删除标志
//                int id= Integer.parseInt(request.getParameter("id")) ;
//                int update = service.update("delete from user where id=?", id);
//                if(update>0){//回去判断
//                    request.getRequestDispatcher("/demo3/main.jsp?isdelete1=t").forward(request,response);
//                }else{
//                    response.sendRedirect(request.getContextPath()+"/demo3/main.jsp?isdelete2=t");
//                }
//
//            }else   if(op.equals("add")){//判断删除标志
//                String name = request.getParameter("name");
//                String sex = request.getParameter("sex");
//
//                int update = service.update("insert user(name,sex) values(?,?)", name,sex);
//                if(update>0){//回去判断
//                    request.getRequestDispatcher("main.jsp?isadd1=t").forward(request,response);
//                }else{
//                    response.sendRedirect("main.jsp?isadd2=t");
//                }
//
//            }else {
//                response.sendRedirect("main.jsp?feifa=t");
//            }
//
//        }else{//空的回去
//            response.sendRedirect("main.jsp?feifa=t");
//        }*/
//        out.flush();
//        out.close();
//
//    }
//}
